<style lang="less">
@import "../../styles/common.less";
</style>

<template>
  <div>
    
    <Form :label-width="100">
      <Card>
        <p slot="title">商家默认费率</p>

        <Row type="flex" justify="start">
          <Col span="12">
            <FormItem label="商家默认费率">
              <Input
                v-model="courierAppCode"
                style="width:80%"
                :maxlength="100"
                placeholder="费率单位：万分之一,如60表示按0.6%收费"
              />
			  <p>费率单位：万分之一,如60表示按0.6%收费</p>
            </FormItem>
          </Col>
        </Row>
        <Button type="primary" size="large" @click="changeCourierSetting()" :loading="loading">保存</Button>
      </Card>
    </Form>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      loading: false,
      courierAppCode: ''
    };
  },
  methods: {
    changeCourierSetting() {
      this.loading = true;
      let options = {
        settings: [
          {
            name: "BILL_RATE_MERCHANT",
            value: this.courierAppCode
          }
        ]
      };
      this.$http.post("/admin/changeParameter", this.common.request(options)).then(
        response => {
          this.loading = false;
          if (response.data.body.status.statusCode == 0) {
            var data = response.data.body.data;
            this.$Notice.success({
              desc: "已经成功保存物流参数",
              duration: 2
            });
          } else {
            this.$Notice.success({
              title: "失败",
              desc: response.data.body.status.errorDesc,
              duration: 2
            });
          }
        },
        response => {
          this.loading = false;
          this.$Message.error("出错了，请稍后重试");
        }
      );
    },
    inquiryParameter(name) {
      let options = {
        name: name
      };
      this.$http.post("/inquiryParameter", this.common.request(options)).then(
        response => {
          if (response.data.body.status.statusCode == 0) {
              this.courierAppCode = response.data.body.data.value;
          }
        },
        response => {}
      );
    }
  },
  created() {},
  mounted() {
    this.inquiryParameter("BILL_RATE_MERCHANT");
  },
  destroyed() {}
};
</script>
<style>

</style>
